﻿using Draco.OWF.Metadata;
using Draco.OWF.RT.Engine;
using System;

namespace Draco.OWF.RT.Impl
{
    public class JobContext : IJobContext
    {
        protected IEngineContext m_EngineContext = null;
        protected IJobContext m_ParentContext = null;
        protected String m_SessionId = Guid.NewGuid().ToString();
        protected WorkflowModel m_ProcessDefinition;

        /// <summary>
        /// SessionId
        /// </summary>
        public virtual string SessionId
        {
            get
            {
                return m_SessionId;
            }
            set
            {
                if (m_SessionId != null) m_SessionId=value;
            }
        }

        public virtual IJobContext ParentContext
        {
            get { return m_ParentContext; }
        }
        /// <summary>
        /// 
        /// </summary>
        public virtual IEngineContext EngineContext
        {
            get { return this.EngineContext; }
        }

        public virtual WorkflowModel ProcessDefinition
        {
            get { return m_ProcessDefinition; }
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="processInstance"></param>
        public JobContext(WorkflowModel process)
            : this(process, null)
        {
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="processInstance"></param>
        /// <param name="parent"></param>
        public JobContext(WorkflowModel process,IJobContext parent)
        {
            if (process == null)
                throw new ArgumentNullException();
            m_ProcessDefinition = process;
            m_ParentContext = parent;
        }
    }
}
